package v1

import (
	"github.com/gin-gonic/gin"
	"hytx_media/models"
	"fmt"
	"hytx_media/pkg/app"
	"net/http"
)


func Test(c *gin.Context)  {
	appG := app.Gin{C: c}

	rows,_:=models.DB.Table("places").Select("id,name,pid,level").Rows()
	var m map[int]map[string]string       //声明变量
	m = make(map[int]map[string]string)  //分配内存

	i := 0
	for rows.Next() {
		var id string
		var name string
		var pid string
		var level string
		_ = rows.Scan(&id, &name, &pid, &level)
		fmt.Println(i)
		m[i] = map[string]string{
			"id" : id,
			"name" : name,
			"pid" : pid,
			"level" : level,
		}
		fmt.Printf("rows id = %s, value = %s, pid = %s, level = %s", id, name, pid, level)
		i++
	}

	//fmt.Println(m)

	appG.ResponseMsg(http.StatusOK, "ok", m)
}
